package com.omar.labs.tamtamy.XML;

import com.omar.labs.tamtamy.ContentFile;
import com.omar.labs.tamtamy.TagList;
import com.omar.labs.tamtamy.utils.XMLUtility;

public class XMLContentFile extends ContentFile {
	
	public XMLContentFile(String xml) {
		super();
		
		this.id = Long.parseLong(XMLUtility.getNodeValue(xml, "id"));
		this.title = XMLUtility.getNodeValue(xml, "title");
		this.description = XMLUtility.getNodeValue(xml, "description");
		this.creationDate = XMLUtility.getNodeValueWithAttribute(xml, "creationDate", "class=\"sql-timestamp\"");
		this.userID = XMLUtility.getNodeValue(xml, "userID");
		this.languageCode = XMLUtility.getNodeValue(xml, "languageCode");
		this.network = XMLUtility.getNodeValue(xml, "network");
		this.permission = XMLUtility.getNodeValue(xml, "permission");
		this.discussionPermission = XMLUtility.getNodeValue(xml, "discussionPermission");		
		this.updateDate = XMLUtility.getNodeValueWithAttribute(xml, "updateDate", "class=\"sql-timestamp\"");
		this.favouriteCounter = XMLUtility.getNodeValue(xml, "favouriteCounter");
		this.highlight = XMLUtility.getNodeValue(xml, "highlight");
		this.numberOfComments = XMLUtility.getNodeValue(xml, "numberOfComments");
		this.rateEnabled = XMLUtility.getNodeValue(xml, "rateEnabled");
		this.tags = XMLUtility.getNodesValue(xml, "string");
		this.rate = XMLUtility.getNodeValue(xml, "rate");
		this.ratesNumber = XMLUtility.getNodeValue(xml, "ratesNumber");
		this.commentList = XMLUtility.getNodesValue(xml, "long");
		this.views = XMLUtility.getNodeValue(xml, "views");
		this.downloads = XMLUtility.getNodeValue(xml, "downloads");
		
		this.size = XMLUtility.getNodeValue(xml, "size");
		this.contentUrl = XMLUtility.getNodeValue(xml, "contentUrl");
		this.contentFileName = XMLUtility.getNodeValue(xml, "contentFileName");
		this.thumbnailPresent = Boolean.parseBoolean(XMLUtility.getNodeValue(xml, "thumbnailPresent"));
		this.thumbnailSmall = XMLUtility.getNodeValue(xml, "thumbnailSmall");
		this.thumbnailRect = XMLUtility.getNodeValue(xml, "thumbnailRect");
		this.thumbnailMedium = XMLUtility.getNodeValue(xml, "thumbnailMedium");
		this.thumbnailOriginal = XMLUtility.getNodeValue(xml, "thumbnailOriginal");
		this.contentType = XMLUtility.getNodeValue(xml, "contentType");
		this.contentTypeCategory = XMLUtility.getNodeValue(xml, "contentTypeCategory");			
	}

}
